#!/bin/bash
SCRIPT_BASE_DIR=$( dirname "${BASH_SOURCE[0]}" )
source "${SCRIPT_BASE_DIR}/common/fs_utils.sh"


function usage () {
    echo "Usage: $( basename ${0} ) [ -h | -1 | -2 ] <src_path> <dst_path>"
    echo "    -1 : 连接qemu instance 1 (fd00::eb:1)"
    echo "    -2 : 连接qemu instance 2 (fd00::eb:2)"
    echo "    <src_path>: path on qemu"
    echo "    <dst_path>: path on local host"
    echo "    -h : 打印本信息"
    exit 1
}

qemu=""
shfCnt=0
while getopts ":h12" args
do
    shfCnt=$(( ${shfCnt} + 1 ))
    case "${args}" in
    h)
        usage
        ;;
    1)
        qemu=1
        ;;
    2)
        qemu=2
        ;;
    *)
        usage
        ;;
    esac
done

if [ -z "${qemu}" ]
then 
    usage
fi

shift "${shfCnt}"

if [ $# -lt 2 ]
then
   usage
fi

src="$1"
dst="$2"

echo rsync -av "root@[fd00::eb:${qemu}]":${src} ${dst}
rsync -av "root@[fd00::eb:${qemu}]":${src} ${dst}
